{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "45754419",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "import numpy as np\n",
    "import math"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "77182b36",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.0\n",
      "-2.4492935982947064e-16\n",
      "{'A': 1, 'B': 2}\n",
      "['A', 'B', 'C', 'D', 'E']\n"
     ]
    }
   ],
   "source": [
    "a = 4\n",
    "print(math.sqrt(a))\n",
    "b = 2*math.pi\n",
    "print(math.sin(b))\n",
    "\n",
    "c = {\"A\":1,\"B\":2,\"C\":3}\n",
    "c.pop(\"C\")\n",
    "print(c)\n",
    "c.update({\"C\": 3})\n",
    "\n",
    "a = [1,2,3,4,5]\n",
    "b = [\"A\",\"B\",\"C\",\"D\",\"E\"]\n",
    "\n",
    "def print_word(*arg):\n",
    "    for x in arg:\n",
    "        print(x)\n",
    "print(b)\n",
    "\n",
    "def print_word(**arg):\n",
    "    for k,v in arg.items():\n",
    "        print(k,v)\n",
    "print_word"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "923c8dfd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[38.0, 28.0, 24.0, 20.0, 23.0, 39.0, 28.0, 37.0, 40.0, 28.0, 32.0, 32.0, 26.0, 39.0, 38.0, 27.0, 28.0, 38.0, 21.0, 23.0, 39.0, 28.0, 39.0, 25.0, 37.0, 26.0, 37.0, 28.0, 39.0, 35.0, 36.0, 34.0, 31.0, 27.0, 38.0, 24.0, 22.0, 21.0, 39.0, 22.0, 24.0, 35.0, 34.0, 35.0, 35.0, 23.0, 22.0, 30.0, 34.0, 33.0, 28.0, 27.0, 27.0, 34.0, 36.0, 25.0, 25.0, 28.0, 27.0, 39.0, 39.0, 28.0, 35.0, 25.0, 22.0, 29.0, 40.0, 20.0, 28.0, 40.0, 40.0, 26.0, 23.0, 31.0, 37.0, 35.0, 23.0, 21.0, 37.0, 40.0, 28.0, 28.0, 38.0, 35.0, 27.0, 29.0, 33.0, 40.0, 40.0, 40.0, 37.0, 38.0, 27.0, 30.0, 36.0, 38.0, 32.0, 34.0, 24.0] [2825.0, 2592.0, 2187.0, 2019.0, 2196.0, 2959.0, 2246.0, 2696.0, 2897.0, 2419.0, 2759.0, 2431.0, 2235.0, 3040.0, 2719.0, 2354.0, 2572.0, 2794.0, 2061.0, 2082.0, 2767.0, 2365.0, 3000.0, 2093.0, 2998.0, 2212.0, 2955.0, 2227.0, 2923.0, 2681.0, 2757.0, 2718.0, 2626.0, 2322.0, 3049.0, 2382.0, 2017.0, 1975.0, 2865.0, 1977.0, 2172.0, 2913.0, 2818.0, 2591.0, 2816.0, 2327.0, 2292.0, 2419.0, 2654.0, 2693.0, 2384.0, 2449.0, 2481.0, 2566.0, 2887.0, 2367.0, 2399.0, 2524.0, 2519.0, 2778.0, 3133.0, 2271.0, 2576.0, 2183.0, 2017.0, 2301.0, 3182.0, 2207.0, 2420.0, 2819.0, 3020.0, 2315.0, 2266.0, 2496.0, 2993.0, 2730.0, 2341.0, 2175.0, 2675.0, 3180.0, 2348.0, 2242.0, 2731.0, 2962.0, 2449.0, 2311.0, 2640.0, 3179.0, 2837.0, 3015.0, 2838.0, 2872.0, 2550.0, 2558.0, 2640.0, 3110.0, 2636.0, 2623.0, 2307.0]\n"
     ]
    }
   ],
   "source": [
    "f = open('/Users/liuyang/Desktop/python_study/2025summber/python实践/线性回归/data/一元奶茶店销售数据.csv',encoding=\"gbk\")\n",
    "contents = f.readlines()\n",
    "data_tem = []\n",
    "data_price =[]\n",
    "for x in range(1,len(contents)-1):\n",
    "    a = contents[x].find(\",\")\n",
    "    b = contents[x].rfind(\",\")\n",
    "    number = float(contents[x][a+1:b])\n",
    "    prices = float(contents[x][b+1:])\n",
    "    data_tem.append(number)\n",
    "    data_price.append(prices)\n",
    "data_price = np.array(data_price)\n",
    "data_tem = np.array(data_tem)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "test",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
